﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AFT.Parking.Foundation.Caching
{
    /// <summary>
    /// Memcached 缓存接口
    /// </summary>
    public interface IMemcached : ICache
    {
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string GetString(string key);
        T Get<T>(string key);
        MemcachedValue GetWithCas(string key);

        /// <summary>
        /// 批量获取缓存值
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        IDictionary<string, object> GetMulti(IEnumerable<string> keys);
        IDictionary<string, MemcachedValue> GetMultiWithCas(IEnumerable<string> keys);

        /// <summary>
        /// 增加一个缓存
        /// </summary>
        bool Add(string key, string value);
        bool Add(string key, string value, DateTime dt);
        bool Add<T>(string key, T t);
        bool Add<T>(string key, T t, DateTime dt);

        /// <summary>
        /// 替换缓存
        /// </summary>
        bool Replace(string key, string value);
        bool Replace(string key, string value, DateTime dt);
        bool Replace<T>(string key, T t);
        bool Replace<T>(string key, T t, DateTime dt);

        /// <summary>
        /// 设置缓存(不存在则增加缓存，否则覆盖缓存)
        /// </summary>
        bool Set(string key, string value);
        bool Set(string key, string value, DateTime dt);
        bool Set<T>(string key, T t);
        bool Set<T>(string key, T t, DateTime dt);
        MemcachedValue Set(string key, object value, ulong cas);
        MemcachedValue Set(string key, object value, DateTime dt, ulong cas);

        /// <summary>
        /// 移除一个缓存
        /// </summary>
        /// <param name="key"></param>
        bool Delete(string key);
    }
}
